home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / octa209s.zip / octave-2.09 / liboctave / prog-args.h < prev    next >
C/C++ Source or Header  |  1996-03-03  |  2KB  |  91 lines

  1. /*
  2.  
  3. Copyright (C) 1996 John W. Eaton
  4.  
  5. This file is part of Octave.
  6.  
  7. Octave is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU General Public License as published by the
  9. Free Software Foundation; either version 2, or (at your option) any
  10. later version.
  11.  
  12. Octave is distributed in the hope that it will be useful, but WITHOUT
  13. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15. for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with Octave; see the file COPYING.  If not, write to the Free
  19. Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  20.  
  21. */
  22.  
  23. #if !defined (octave_prog_args_h)
  24. #define octave_prog_args_h 1
  25.  
  26. struct
  27. long_options
  28. {
  29.   const char *name;
  30.   int has_arg;
  31.   int *flag;
  32.   int val;
  33. };
  34.  
  35. class
  36. prog_args
  37. {
  38. public:
  39.  
  40.   // These values must match the corresponding defines in getopt.h.
  41.   enum option_argument
  42.     {
  43.       no_arg = 0,
  44.       required_arg = 1,
  45.       optional_arg = 2
  46.     };
  47.  
  48.   prog_args (int argc, char *const *argv, const char *s_opts, const
  49.          long_options* l_opts = 0)
  50.     : xargc (argc), xargv (argv), short_opts (s_opts), long_opts (l_opts)
  51.       {
  52.     init ();
  53.       }
  54.  
  55.   ~prog_args (void) { }
  56.  
  57.   int getopt (void);
  58.  
  59.   const char *optarg (void);
  60.  
  61.   int optind (void);
  62.  
  63. private:
  64.  
  65.   // Number of args.
  66.   int xargc;
  67.  
  68.   // Program args.
  69.   char *const *xargv;
  70.  
  71.   // Single character options.
  72.   const char *short_opts;
  73.  
  74.   // Long options.
  75.   const long_options *long_opts;
  76.  
  77.   void init (void);
  78.  
  79.   prog_args (const prog_args&);
  80.  
  81.   prog_args& operator = (const prog_args&);
  82. };
  83.  
  84. #endif
  85.  
  86. /*
  87. ;;; Local Variables: ***
  88. ;;; mode: C++ ***
  89. ;;; End: ***
  90. */
  91.